/**
 *<p>Copyright: Copyright (c) 2012</p> 
 *<p>Company: SCPII</p>
 *<p>Project:scpii-mobi-page</p>
 *@author xiezhouyan
 *@Date 2013-5-7 上午11:23:56
 *@version 1.0
 *@description:
 */
package com.scpii.mobi.page.service.user.impl;

import java.util.Date;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.scpii.mobi.page.domain.user.UserLink;
import com.scpii.mobi.page.persistence.user.UserLinkMapper;
import com.scpii.mobi.page.service.user.UserLinkService;

@Service
public class UserLinkServiceImpl implements UserLinkService {

	@Resource
	private UserLinkMapper userLinkMapper;

	@Override
	public UserLink selectBySelective(UserLink record) {
		return userLinkMapper.selectBySelective(record);
	}

	@Override
	public void insertSelective(UserLink record, String cardId,
			String cardPassword) {
		UserLink userLink = userLinkMapper.selectBySelective(record);
		if (userLink == null) {
			record.setCardId(cardId);
			record.setCardPassword(cardPassword);
			record.setCreateBy(record.getUserId());
			record.setCreateDt(new Date());
			userLinkMapper.insertSelective(record);
		} else {
			record.setCardId(cardId);
			record.setCardPassword(cardPassword);
			record.setUpdateDt(new Date());
			userLinkMapper.updateByPrimaryKeySelective(record);
		}
	}

}
